<ion-view view-title="账户信息">
 <ion-nav-back-button>
      </ion-nav-back-button>
	<ion-nav-buttons side="right">
	    <button class="button" ng-class="{'button-icon ion-ios-compose-outline':!$root.isEdit,'button-clear':$root.isEdit}" ng-click="$root.toggleEdit();"><span ng-if="$root.isEdit">取消</span></button>
        <button class="button button-icon ion-navicon rotate90" menu-toggle="right"></button>

	</ion-nav-buttons>
    <ion-content class="wrap-light">
    	<h3 class="padding text-center" ng-if="$root.isFirstLogin">请完善账户信息</h3>

		<ion-list class="wrap-light2">
			<form name="accountForm" ng-submit="$root.toggleEdit();update();" novalidate>
				<ion-item class="item item-divider margin-top-large">
				    账户信息
				</ion-item>
				<ion-item class="item-input item-icon-left">
				    <i class="icon ion-log-in dark2"></i>
				    <input type="text" name="username" maxlength="20" readonly placeholder="用户名" ng-model="$root.currentUser.username">
				    <span class="ion-minus-circled" ng-show="accountForm.username.$dirty && accountForm.username.$invalid "></span>
				</ion-item>
				<ion-item class="margin-bottom-large item-input item-icon-left" ng-if="$root.currentUser.emails">
				    <i class="icon ion-email dark2"></i>
				    <input type="text" name="email" maxlength="20" readonly placeholder="邮箱" ng-model="$root.currentUser.emails[0].address">
				    <span class="ion-minus-circled" ng-show="accountForm.email.$dirty && accountForm.email.$invalid "></span>
				</ion-item>
				<a class="button button-block button-light" href="/#/pwmodify">
		            修改密码
		        </a>

				<ion-item class="item item-divider margin-top-large">
				    个人信息
				</ion-item>

				<ion-item class="item-input item-icon-left item-icon-right">
				    <i class="icon ion-person dark2"></i>
				    <input type="text" name="name" maxlength="20" required ng-readonly="!$root.isEdit" placeholder="姓名" ng-model="myInfo.name">
				    <span class="ion-minus-circled" ng-show="accountForm.name.$dirty && accountForm.name.$invalid "></span>
				    <i class="icon dark2" ng-class="{'ion-male': myInfo.sex=='男','ion-female': myInfo.sex=='女'}"></i>
				</ion-item>

				<ion-item class="item-input item-icon-left">
				    <i class="icon ion-heart dark2"></i>
				    <input type="datetime" name="birthday" maxlength="30" required ng-readonly="!$root.isEdit" placeholder="生日" ng-model="myInfo.birthday">
				    <span>{{myInfo.age}}岁</span>
				    <span class="ion-minus-circled" ng-show="accountForm.birthday.$dirty && accountForm.birthday.$invalid "></span>
				</ion-item>

				<ion-item class="item-input item-icon-left" ng-repeat="(label,address) in accountForm.addresses">
				    <i class="icon ion-home dark2"></i>
				    <span>{{label}}</span>
				    <input type="text" name="phone{{$index}}" maxlength="11" required ng-readonly="!$root.isEdit" placeholder="地址" ng-model="address">
				    <span class="ion-minus-circled" ng-show= "accountForm.address.$dirty && accountForm.address.$invalid "></span>
				</ion-item>

				<ion-item class="item-input item-icon-left" ng-repeat="(label, phone) in accountForm.phones">
				    <i class="icon ion-iphone dark2"></i>
				    <input type="text" name="phone{{$index}}" maxlength="11" required ng-readonly="!$root.isEdit" placeholder="手机号码" ng-model="phone">
				    <span>{{label}}</span>
				    <span class="ion-minus-circled" ng-show= "accountForm.phone.$dirty && accountForm.phone.$invalid "></span>
				</ion-item>

				<ion-item class="item-input item-icon-left">
				    <i class="icon ion-email dark2"></i>
				    <input type="email" name="email" maxlength="30" required ng-readonly="!$root.isEdit" placeholder="个人邮箱" ng-model="myInfo.email">
				    <span class="ion-minus-circled" ng-show="accountForm.email.$dirty && accountForm.email.$invalid "></span>
				</ion-item>

				<ion-item class="item-icon-left">
				    <i class="icon ion-android-wifi dark2"></i>
				    <span ng-class="{'balanced':myInfo.status=='在职'}">{{myInfo.state}}</span>
				</ion-item>

		        <button class="button button-block button-balanced" ng-click="updateAccount();" ng-if="isEdit">保存</button>
				<a href="#/home" class="button button-light button-block" ng-if="$root.isFirstLogin">跳过</a>
			</form>
		</ion-list>
	</ion-content>
</ion-view>
